package com.nanbei.rabbit.producer.config;

import org.springframework.amqp.core.*;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @ClassDescription:
 * @JdkVersion: 1.8
 * @Author: libs
 * @Created: 2024/8/28 16:16
 */
@Configuration
public class RabbitFanoutExchangeConfig {
    // 交换机  durable 持久化
    @Bean
    public Exchange fanoutExchange(){
        return ExchangeBuilder.fanoutExchange("fanout_exchange").durable(true).build();
    }

    // 队列
    @Bean
    public Queue fanoutQueue01(){
        return QueueBuilder.durable("fanout_queue_01").build();
    }

    @Bean
    public Queue fanoutQueue02(){
        return QueueBuilder.durable("fanout_queue_02").build();
    }

    // 交换机绑定队列
    @Bean
    public Binding fanoutExchangeBindingQueue01(){
        return BindingBuilder.bind(fanoutQueue01()).to(fanoutExchange()).with("").noargs();
    }

    @Bean
    public Binding fanoutExchangeBindingQueue02(){
        return BindingBuilder.bind(fanoutQueue02()).to(fanoutExchange()).with("").noargs();
    }
}
